package com.example.shengyin.service.impl;

import com.example.shengyin.dao.ArticleMapper;
import com.example.shengyin.entity.Article;
import com.example.shengyin.entity.ArticleSimple;
import com.example.shengyin.entity.Page;
import com.example.shengyin.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.sql.Timestamp;
import java.util.List;

@Service
public class ArticleServiceImpl implements ArticleService {

    @Autowired
    private ArticleMapper articleMapper;

    @Override
    public Article selectById(Long id) {
        return articleMapper.selectById(id);
    }

    @Override
    public int insert(Article article) {
        return articleMapper.insert(article);
    }

    @Override
    public int update(Article article) {
        return articleMapper.update(article);
    }

    @Override
    public int deleteById(Integer id) {
        return articleMapper.deleteById(id);
    }

    @Override
    public int deleteByIds(String ids) {
        return articleMapper.deleteByIds(ids);
    }

    @Override
    public List<Article> selectByNmae(String name,String type,String typecode) {
        return articleMapper.selectByNmae(name,type,typecode);
    }

    @Override
    public List<Article> articleList(Page page, String type, String typecode, String createby, Timestamp start, Timestamp end) {
        return articleMapper.articleList((page.getPage()-1)*page.getLimit(),page.getLimit(),type,typecode,createby,start,end);

    }

    @Override
    public int countTotall(String type, String typecode, String createby, Timestamp start, Timestamp end) {
        return articleMapper.countTotall(type,typecode,createby,start,end);
    }

    @Override
    public List<ArticleSimple> selecthot(int number) {
        return articleMapper.selecthot(number);
    }

    @Override
    public List<ArticleSimple> selectnewwest(int number) {
        return  articleMapper.selectnewwest(number);
    }

    @Override
    public List<ArticleSimple> articleList2(Page page, String type, String typecode, String createby, Timestamp start, Timestamp end) {
        return articleMapper.articleList2((page.getPage()-1)*page.getLimit(),page.getLimit(),type,typecode,createby,start,end);
    }

    @Override
    public List<ArticleSimple> articleList3(Page page, String type, String typecode, String createby, Timestamp start, Timestamp end) {
        return articleMapper.articleList2((page.getPage()-1)*page.getLimit(),page.getLimit(),type,typecode,createby,start,end);
    }

    @Override
    public List<ArticleSimple> selectrecomend(int number) {
        return  articleMapper.selectrecomend(number);
    }




    @Override
    public List<ArticleSimple> Eventshot(int number) {
        return articleMapper.Eventshot(number);
    }

    @Override
    public List<ArticleSimple> Eventsnewwest(int number) {
        return  articleMapper.Eventsnewwest(number);
    }
    @Override
    public List<ArticleSimple> Eventsrecomend(int number) {
        return  articleMapper.Eventsrecomend(number);
    }
}
